<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
use App\Topic;

class SouController extends Controller
{
   public function sou(Request $req){
    $topics = new Topic();
      //$data = $topics->getTopics();
    $rs = $req->input('keywords');//获取value值
         
         if($rs == ''){
             echo '输入条件不能为空';
             exit();
         }
         //进行模糊查询
      $data = $topics->where('title','like',"%$rs%")->paginate(2);
      //print_r($data);
        if($data == ''){
           echo '抱歉，没有符合您的搜索条件。请用不同的关键词再试试';
            exit();
        }

//dd($data);
//dd($data[0]->title);
            return view('index',['data'=>$data]);
   }
}
